package part13;

import java.io.PrintStream;
import java.util.Formatter;

/**
 * @author wcj
 * @Date 2021/5/24 15:40
 * @Version 1.0
 */
public class Part135 {

    private String name;
    private Formatter f;

    public Part135(String s, Formatter f) {
        this.name = s;
        this.f = f;
    }

    public void move(int x, int y) {
        f.format("%s,this String is at(%d,%d)", name, x, y);
    }

    /**
     * 格式化输出的Formatter类，这个类是java种格式化功能的集成类，重载了多个构造器，可以接收多种输出目的地
     *
     * @param args
     */
    public static void main(String[] args) {
        PrintStream alias = System.out;
        Part135 wcj = new Part135("wcj", new Formatter(System.out));
        Part135 bss = new Part135("bss", new Formatter(alias));
        wcj.move(2, 5);
        bss.move(2, 5);
    }
}
